/**
 * Copyright (C) 2011 PROCESSBASE Ltd.
 * This library is free software; you can redistribute it and/or modify it under the terms
 * of the GPL as published by the Free Software Foundation version 3 of the License.
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public License along with this
 * program; if not, see <http://www.gnu.org/licenses/>.
 */
package org.processbase.touchprocess.ui.demo;

//import com.invient.vaadin.charts.Color.RGB;
import com.vaadin.ui.VerticalLayout;
//import com.invient.vaadin.charts.InvientCharts;
//import com.invient.vaadin.charts.InvientCharts.DecimalPoint;
//import com.invient.vaadin.charts.InvientCharts.Series;
//import com.invient.vaadin.charts.InvientCharts.SeriesType;
//import com.invient.vaadin.charts.InvientCharts.XYSeries;
//import com.invient.vaadin.charts.InvientChartsConfig;
//import com.invient.vaadin.charts.InvientChartsConfig.AxisBase.AxisTitle;
//import com.invient.vaadin.charts.InvientChartsConfig.BarConfig;
//import com.invient.vaadin.charts.InvientChartsConfig.CategoryAxis;
//import com.invient.vaadin.charts.InvientChartsConfig.DataLabel;
//import com.invient.vaadin.charts.InvientChartsConfig.NumberYAxis;
//import com.invient.vaadin.charts.InvientChartsConfig.PointConfig;
//import com.invient.vaadin.charts.InvientChartsConfig.XAxis;
//import com.invient.vaadin.charts.InvientChartsConfig.YAxis;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Random;

/**
 *
 * @author marat
 */
public class BarChartDemo extends VerticalLayout {
    
//    private HashMap<String, RGB> colors = new HashMap<String, RGB>();

//    public void initUI() {
//        try {
//            BarConfig barCfg1 = new BarConfig();
//            barCfg1.setAnimation(true);
//            barCfg1.setColor(new RGB(134, 98, 34 ));
//            barCfg1.setDataLabel(new DataLabel(true));
//            barCfg1.setAllowPointSelect(true);
//            barCfg1.setShowInLegend(true);
//            
//            BarConfig barCfg2 = new BarConfig();
//            barCfg2.setAnimation(true);
//            barCfg2.setColor(new RGB(56, 230, 135));
//            barCfg2.setDataLabel(new DataLabel(true));
//            barCfg2.setAllowPointSelect(true);
//            barCfg2.setShowInLegend(true);
//
//            ArrayList<Double> processAll = new ArrayList<Double>();
//            ArrayList<Double> processToday = new ArrayList<Double>();
//            ArrayList<String> processNames = new ArrayList<String>();
//            for (int i =0; i < 7 ; i++) {
//                 Random x = new Random();
//                processNames.add("Process " + i);
//                processAll.add(new Double(x.nextInt(100)));
//                processToday.add(new Double(x.nextInt(100)));
//            }
//            ArrayList<XYSeries> xySeries = new ArrayList<XYSeries>();
//
//            XYSeries seriesDataAll = new XYSeries("All", SeriesType.COLUMN, barCfg1);
//            seriesDataAll.setSeriesPoints(getPoints(seriesDataAll, processAll));
//            xySeries.add(seriesDataAll);
//
//            XYSeries seriesDataToday = new XYSeries("Today", SeriesType.COLUMN, barCfg2);
//            seriesDataToday.setSeriesPoints(getPoints(seriesDataToday, processToday));
//            xySeries.add(seriesDataToday);
//
//            removeAllComponents();
//            InvientCharts ich = createchart(processNames, xySeries);
//            ich.setWidth("100%");
//            ich.setHeight("100%");
//            addComponent(ich);
//        } catch (Exception ex) {
//            ex.printStackTrace();
//        }
//    }
//
//    private InvientCharts createchart(ArrayList<String> processNames, ArrayList<XYSeries> xySeries) {
//
//        InvientChartsConfig chartConfig = new InvientChartsConfig();
//        chartConfig.getTitle().setText("BarChart Demo");
//        chartConfig.getSubtitle().setText("Source: PROCESSBASSE BPMS");
//
//        CategoryAxis xAxis = new CategoryAxis();
//        xAxis.setCategories(processNames);
//        LinkedHashSet<XAxis> xAxesSet = new LinkedHashSet<InvientChartsConfig.XAxis>();
//        xAxesSet.add(xAxis);
//        chartConfig.setXAxes(xAxesSet);
//
//        NumberYAxis yAxis = new NumberYAxis();
//        yAxis.setAllowDecimals(false);
//        yAxis.setTitle(new AxisTitle("Process count"));
//        LinkedHashSet<YAxis> yAxesSet = new LinkedHashSet<InvientChartsConfig.YAxis>();
//        yAxesSet.add(yAxis);
//        chartConfig.setYAxes(yAxesSet);
//
//        InvientCharts chart = new InvientCharts(chartConfig);
//
//        for (XYSeries xy : xySeries) {
//            chart.addSeries(xy);
//        }
//        return chart;
//    }
//
//    private LinkedHashSet<DecimalPoint> getPoints(Series series, ArrayList<Double> values) {
//        LinkedHashSet<DecimalPoint> points = new LinkedHashSet<DecimalPoint>();
//        for (double value : values) {
//            points.add(new DecimalPoint(series, value));
//        }
//        return points;
//    }
//    
}
